#!/bin/bash
echo "计算 120 秒内磁盘 $1 平均IO使用率"

INTERVAL=120
result1=$(cat /proc/diskstats|grep "$1 "|awk '{print $13}')
sleep ${INTERVAL}s
result2=$(cat /proc/diskstats|grep "$1 "|awk '{print $13}')

now=$(date '+%Y-%m-%d %H:%M:%S')

disk_io=$(echo "scale=4; ($result2 - $result1) / $INTERVAL" | bc)

disk_io=$(printf "%.4f" $disk_io)

echo $now 
echo "I/O Utilization: $disk_io %"

